<template>
  <el-card shadow="never" :body-style="{ padding: '20px 20px 20px 20px' }">
    <el-upload
        class="upload-demo"
        ref="upload"
        action="https://jsonplaceholder.typicode.com/posts/"
        :on-preview="handlePreview"
        :on-remove="handleRemove"
        :auto-upload="false">
      <el-button
          slot="trigger"
          size="small"
          type="primary"
          icon="el-icon-folder">选择文件
      </el-button>
      <el-button
          style="margin-left: 10px;"
          size="small" type="success"
          @click="submitUpload"
          icon="el-icon-upload2">开始上传
      </el-button>
    </el-upload>
  </el-card>
</template>
<script>
export default {
  // data() {
  //   return {
  //     test: true
  //   };
  // },
  methods: {
    submitUpload() {
      this.$refs.upload.submit();
    },
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePreview(file) {
      console.log(file);
    }
  }
};
</script>
